Mb/events port - #218
Draft
m-bossart wants to merge 18 commits into
Draft
Conversation
Adds supports_events(::Type{<:PSY.Component}) plus
get_initial_parameter_value/get_parameter_multiplier methods for the
event parameter types, enabling outage-event discovery and defaults.
Add PowerOperationsProblemTemplate.events, set_event_model!/get_event_models so a template can hold EventModels ahead of build-time distribution to DeviceModels.
Populate EventModel.attribute_device_map from the system's supplemental attributes during template validation, validate each event's time-series mapping, and distribute the event to every DeviceModel whose device type carries the attribute. Preserve event-model identity across the template deep copy performed at DecisionModel construction (mirroring the existing PNM-matrix-sharing trick) so callers can inspect discovery results on the same EventModel object they attached to the template. Also fix a name collision from the earlier event-model work: POM's get_value(::StateVariableValueCondition) was defined without qualifying IOM.get_value, which created a separate local generic function that shadowed IOM's get_value(::InitialCondition) for every other unqualified caller in the package (storage, hybrid, thermal generation, AGC), silently breaking all initial-conditions-consuming builds.
Two distinct event models of the same contingency type discovering the same device type can't both be registered under the device model's single (contingency type, device type) events slot. Replace the silent-skip guard in _build_device_model_events! with a loud error when the existing registration belongs to a different event model than the one being processed; re-discovering the same event model for the same key stays a no-op. Add a covering test case. Also reword the _deepcopy_template override comment to describe the deepcopy-unsafe solver-cache behavior directly instead of citing a PR number.
Wires DeviceModel.events into the ArgumentConstructStage: add_parameters! creates AvailableStatusParameter and AvailableStatusChangeCountdownParameter containers for devices carrying a matching supplemental attribute, and a generic add_to_expression! offsets those parameters into the system balance via _balance_expression_targets, replacing PSI's four per-network methods with one. add_event_arguments! now overrides the no-op stub for PSY.StaticInjection devices.
Loads (StaticPowerLoad/PowerLoadDispatch/PowerLoadInterruption) and FixedOutput devices now inject an ActivePowerOffsetParameter (and ReactivePowerOffsetParameter on reactive-capable networks) directly into the system balance expression when an event is attached, on top of the generic status/countdown parameters from the StaticInjection default.
…vices Implements add_event_constraints! for ThermalGen/RenewableGen/ElectricLoad across active-only and reactive-capable networks, bounding dispatch by available capacity during an outage event and adding a quadratic reactive power bound on reactive-capable networks.
Ports HydroGen/HydroPumpTurbine/EnergyReservoirStorage add_event_constraints! methods and their pump/input-output contingency-constraint helpers, plus fixes a get_variable/add_constraints_container! instance-vs-type bug in the shared reactive-power contingency helper (never previously exercised by any test).
Covers full-template build+solve across CopperPlate/PTDF/DCP/ACP network models with a FixedForcedOutage event, the PTDF two-target balance offset and ACP reactive-offset paths for load events, and a recurrent-solve mock test confirming a forced outage drives thermal output to zero. Also strengthens the initial-conditions exclusion test to confirm event parameters land in the main container while staying absent from the IC container.
…es style Aligns the new E2E thermal-outage testset with the naming convention already established in test_model_decision.jl (both are exported by IOM and used unqualified there).
The prior testset only checked that ReactivePowerOffsetParameter and ReactivePowerBalance both exist, which proves nothing about the offset being wired into the balance (the expression is allocated for every ACP build regardless of events). Add a recurrent-solve mock testset that checks JuMP.coefficient of the offset parameter's variable in the balance expression directly, so the test fails if the wiring is ever removed.
Adds an Outage events subsection covering the availability parameters and per-device-family outage constraints added when an EventModel is attached to a template. public.md needs no changes: it registers symbols via a blanket @autodocs, which already picks up the new exports.
Record the completed event framework port in pom_port_plan.md (Workstream C and execution order), and add the SDD plan and design spec artifacts for the branch.
Add an objective to the forced-outage mock test so it fails when ActivePowerOutageConstraint is removed, assert the constraint's baked RHS equals the device's max active power, cover the FixedOutput offset path, and smoke-test the event condition accessors. Also correct the ReactivePowerOutageConstraint docstring/docs math to match the max((Q^max)^2, (Q^min)^2) implementation, and update the stale "no event framework" claim in .claude/CLAUDE.md.
|
Performance Results
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft of porting events